//package io.xxx.mario.task;
//
//import com.alibaba.schedulerx.common.domain.ExecuteMode;
//import com.alibaba.schedulerx.common.domain.JobType;
//import com.alibaba.schedulerx.common.domain.TimeType;
//import com.aliyuncs.IAcsClient;
//import com.aliyuncs.exceptions.ClientException;
//import com.aliyuncs.schedulerx2.model.v20190430.CreateJobRequest;
//import com.aliyuncs.schedulerx2.model.v20190430.CreateJobResponse;
//import com.baomidou.mybatisplus.core.toolkit.IdWorker;
//import io.xxx.mario.task.job.OncePushJob;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.ArrayList;
//import java.util.List;
//
//@Slf4j
//@RestController
//@RequestMapping("/demo/task")
//public class TaskDemoController {
//
//    @Autowired
//    private IAcsClient acsClient;
//
//    @PostMapping("/create")
//    public void createJob(@RequestParam String dateTime) throws ClientException {
//        long id = IdWorker.getId();
//        CreateJobRequest cjReq = new CreateJobRequest();
//        cjReq.setSysRegionId("cn-shenzhen");
//        cjReq.setNamespace("889997bc-26b4-4a48-8236-89887f4bf844");
//        cjReq.setGroupId("mario");
//        cjReq.setJobType(JobType.JAVA.getKey());
//        cjReq.setExecuteMode(ExecuteMode.STANDALONE.getKey());
//        cjReq.setDescription("单次测试任务");
//        cjReq.setName("OncePushJob-" + id);
//        cjReq.setClassName(OncePushJob.class.getName());
//        cjReq.setTimeType(TimeType.ONE_TIME.getValue());
//        cjReq.setTimeExpression(dateTime);
//        cjReq.setTimeoutEnable(true);
//        cjReq.setTimeoutKillEnable(true);
//        cjReq.setFailEnable(true);
//        cjReq.setTimeout(12300L);
//        List<CreateJobRequest.ContactInfo> contactInfosList = new ArrayList<>();
//        CreateJobRequest.ContactInfo contactInfo = new CreateJobRequest.ContactInfo();
//        contactInfo.setUserName("db");
//        contactInfo.setUserPhone("15768888254");
//        cjReq.setContactInfos(contactInfosList);
//        cjReq.setTaskMaxAttempt(2);
//        cjReq.setTaskAttemptInterval(1000 * 30);
//        CreateJobResponse cjResp = acsClient.getAcsResponse(cjReq);
//        if (!cjResp.getSuccess()) {
//            log.error("创建任务失败");
//            throw new RuntimeException(cjResp.getMessage());
//        }
//    }
//}
